package thread;

public class ThreadDemo12 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
           for (int i =0;i < 5;i++){
               System.out.println("我是一个线程,正在工作中");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
            System.out.println("线程执行结束");
        });
        t.start();
        t.join();//线程操作,谁等谁?(让main线程等待t进程结束)
        System.out.println("这是主线程,我们期望这个日志在线程t结束之后打印");
    }
}
